import requests
from user_agent_get import userAgentGet
from pyquery import PyQuery
from time import sleep


for x in range(2,5):
    url='https://www.qidian.com/rank/yuepiao/page{}'.format(x)
    headers={'user-Agent':userAgentGet('firefox').userAgentGetValue()}

    respon=requests.get(url,headers=headers)

    mypy=PyQuery(respon.text)
    author_q=mypy(".book-mid-info").items()

    with open("code1/test{}.txt".format(x+1),'w',encoding='utf-8') as f:
        for i in author_q:
            str1=""+"-------------------\n"
            str1=str1+"小说题目："+i("h4").text()+"\n"
            str1=str1+"作者："+i(".name").text()+"\n"
            str1=str1+"小说类型："+i("a[data-eid='qd_C42']").text()+"\n"
            str1=str1+"小说总体描述："+i(".intro").text()+"\n-------------------------\n"
            f.write(str1)
    sleep(2)